/*    */ package com.newcrm.webapi;
/*    */ 
/*    */ import com.newcrm.bean.CaptchaEntity;
/*    */ import com.newcrm.businessarchives.CaptchaEntityManager;
/*    */ import com.newcrm.util.Util;
/*    */ import java.io.IOException;
/*    */ import java.io.OutputStream;
/*    */ import java.io.PrintWriter;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServlet;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ 
/*    */ public class CaptchaServlet extends HttpServlet
/*    */ {
/*    */   private static final long serialVersionUID = 2566554710409605028L;
/*    */ 
/*    */   public void doGet(HttpServletRequest request, HttpServletResponse response)
/*    */     throws ServletException, IOException
/*    */   {
/* 47 */     String getCode = Util.getURLParameter(request.getParameter("code"));
/* 48 */     String companyName = Util.getURLParameter(request
/* 49 */       .getParameter("companyName"));
/* 50 */     String tmp = Util.getURLParameter(request.getParameter("isReload"));
/*    */ 
/* 52 */     boolean isReload = false;
/* 53 */     if ("1".equals(tmp)) {
/* 54 */       isReload = true;
/*    */     }
/* 56 */     String type = null;
/*    */ 
/* 58 */     if (companyName.contains("广州")) {
/* 59 */       type = "gz";
/*    */     }
/* 61 */     CaptchaEntityManager manager = CaptchaEntityManager.getInstance();
/* 62 */     CaptchaEntity captchaEntity = manager.get(type, isReload);
/* 63 */     if (captchaEntity == null) {
/* 64 */       return;
/*    */     }
/* 66 */     if ("1".equals(getCode))
/*    */     {
/* 68 */       response.setContentType("text/html;charset=utf-8");
/* 69 */       PrintWriter out = response.getWriter();
/*    */ 
/* 71 */       JSONObject jsonObject = new JSONObject();
/* 72 */       jsonObject.put("code", captchaEntity.code);
/* 73 */       out.println(jsonObject);
/* 74 */       out.flush();
/* 75 */       out.close();
/* 76 */       return;
/*    */     }
/* 78 */     response.setContentType("image/jpeg");
/* 79 */     OutputStream out = response.getOutputStream();
/* 80 */     out.write(captchaEntity.image);
/* 81 */     out.flush();
/* 82 */     out.close();
/*    */   }
/*    */ 
/*    */   public void doPost(HttpServletRequest request, HttpServletResponse response)
/*    */     throws ServletException, IOException
/*    */   {
/* 99 */     doGet(request, response);
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.CaptchaServlet
 * JD-Core Version:    0.6.1
 */